package PlugIn;



/**
 * @author      Erwan Osouf, Lucas Ennouchi
 * @version     1.0                                
 * @since       29/01/2012
 */

public class PlugInImp implements PlugIn {
	
	private PlugInControl controller;
	private PlugInUI view;
	private PlugInModel abstraction;
	
	/**
	 * Construtor
	 * @param view the view
	 * @param controller the controller
	 * @param abstraction the abstraction
	 */
	public PlugInImp(PlugInUI view, PlugInControl controller,PlugInModel abstraction) {
		super();
		this.controller = controller;
		this.view=view;
		this.abstraction=abstraction;
		this.getView().getCommandButton().addActionListener(this.controller);
	}
	
	/**
	 * Constructor
	 * @param abstraction
	 */
	public PlugInImp(PlugInModel abstraction) {
		super();
		this.view= new PlugInUI(abstraction.getName());
		this.controller = new PlugInControl(view, abstraction);
		this.abstraction = abstraction;
		this.getView().getCommandButton().addActionListener(this.controller);
	}


	@Override
	/**
	 * runs the abstraction
	 */
	public void run() {
		getAbstraction().run();	
	}


	@Override
	/**
	 * get the result
	 * @return String the result in a string
	 */
	public String getResult() {
		return getAbstraction().getResult();
	}


	/**
	 * get the view
	 * @return view the view
	 */
	public PlugInUI getView() {
		return view;
	}

/**
 * return the abstraction
 * @return abstraction
 */
	public PlugInModel getAbstraction() {
		return abstraction;
	}
	
	

}
